import request from "@/utils/request";
import { AxiosPromise } from "axios";
import { ItemPageResult, ItemForm } from "./types";

/**
 * 赛队列表
 *
 * @param queryParams
 */
export function getTeamList(queryParams?: any): AxiosPromise<ItemPageResult> {
  return request({
    url: "/adminApi/team/page",
    method: "get",
    params: queryParams,
  });
}

/**
 * 队伍统计列表
 *
 * @param queryParams
 */
export function getTeamStatisticsList(
  queryParams?: ItemForm
): AxiosPromise<ItemPageResult> {
  return request({
    url: "/adminApi/team/statistics",
    method: "get",
    params: queryParams,
  });
}

/**
 * 新增赛队人员
 *
 * @param data
 */
export function teamCreate(data: ItemForm) {
  return request({
    url: "/adminApi/team/create",
    method: "post",
    data: data,
  });
}

/**
 * 修改赛队人员
 *
 * @param data
 */
export function teamUpdate(data: ItemForm) {
  return request({
    url: "/adminApi/team/update",
    method: "put",
    data: data,
  });
}

/**
 * 删除赛队人员
 *
 * @param id
 */
export function teamDelete(id: number) {
  return request({
    url: "/adminApi/team/delete?id=" + id,
    method: "delete",
  });
}

/**
 * 下载模版
 *
 */
export function downloadTemplate() {
  return request({
    url: "/adminApi/team/download",
    method: "get",
    responseType: "arraybuffer",
  });
}

/**
 * 导入题目
 *
 * @param data
 */
export function teamUpload(data: any) {
  return request({
    url: "/adminApi/team/upload",
    method: "post",
    data: data,
    headers: {
      "Content-Type": "multipart/form-data",
    },
  });
}
